/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.matheval;
import simhya.matheval.operator.OperatorDefinition;

/**
 *
 * @author Luca
 */
public class UnaryOperatorNode extends OperatorNode {

    public UnaryOperatorNode(OperatorDefinition op) {
        super(op,1);
    }


    

   @Override
    void computeValue() {
        children[0].computeValue();
        super.value = operator.compute(children[0].value);
    }

    @Override
    void computeValue(SymbolArray varReference) {
        children[0].computeValue(varReference);
        super.value = operator.compute(children[0].value);
    }

    @Override
    void computeValue(int evaluationCode) {
        if (random || super.evaluationCode != evaluationCode) {
            super.evaluationCode = evaluationCode;
            children[0].computeValue(evaluationCode);
            super.value = operator.compute(children[0].value);
        }
    }

    @Override
    void computeValue(SymbolArray varReference, int evaluationCode) {
        if (random || super.evaluationCode != evaluationCode) {
            super.evaluationCode = evaluationCode;
            children[0].computeValue(varReference,evaluationCode);
            super.value = operator.compute(children[0].value);
        }
    }
}
